import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import './style/global.less';
import './style/index.css';
import './assets/icon/iconfont';
import SvgIcon from '@/components/SvgIcon/index.vue';
import './components/SvgIcon/index.ts';
import { deviceDetection } from '@/utils';
import { useAppStore } from '@/store/modules/app';

const app = createApp(App);
app.component('svg-icon', SvgIcon);
app.use(store);
app.use(router);
app.mount('#app');

const appStore = useAppStore();
const isMobile = deviceDetection();
// 监听容器
window.addEventListener('resize', () => {
  if (isMobile) return;

  const width = window.innerWidth;
  if (width <= 700) {
    appStore.toggleDevice('mobile');
  } else {
    appStore.toggleDevice('desktop');
  }
});
